﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Fcdbas.Core;
using Fcdbas.CodeBuilder.ety;

namespace Fcdbas.CodeBuilder
{
    public partial class NewModel : Form
    {
        public fnd_design_lu_tab newEtyLogicUnit = new fnd_design_lu_tab();

        public NewModel()
        {
            InitializeComponent();
        }

        public NewModel(int flag)
        {
            this.Flag = flag;
            InitializeComponent();
        }


        public int Flag
        {
            get;
            set;
        }


        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void txtName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                btnOK_Click(sender, e);
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            fnd_design_lu_tab eyLuTab = new fnd_design_lu_tab();
            eyLuTab.module = txtName.Text;
            eyLuTab.rowversion = DateTime.Now;
            Dictionary<SalString, SalString> pars = new Dictionary<SalString, SalString>();
            pars.Add("@module", eyLuTab.module);

            int iRst=eyLuTab.Execute("insert into fnd_design_lu_tab (module,rowversion,rowid)values(@module,now(),uuid())",pars);
            if (iRst == 0)
            {
                MessageBox.Show("保存失败。");
                return;
            }
            else
            {
                newEtyLogicUnit = eyLuTab;
                MessageBox.Show("保存成功。");
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            
        }
    }
}
